import * as api from '../api'
export default(state,action)=>{
    state = state || {radioList:[],slider:[]};
    switch(action.type){
        case 'recom_init':
            return {radioList:action.radioList,slider:action.slider}
        default:
            return state;
    }
}

export const recommend = () => (dispatch) =>{
    fetch(api.RECOMMEND).then(response=>response.json()).then(result=>{
        // console.log(result)
        if(result.errno===0){
            dispatch({type:'recom_init',radioList:result.data.radioList,slider:result.data.slider})
        }
    })
}